import groovy.sql.Sql

def p = new Properties()

def f = new File('../config/datasource.properties')
p.load(new InputStreamReader(new FileInputStream(f), 'utf-8'))

def db = Sql.newInstance(p['dataSource.url'], p['dataSource.user'], 
	p['dataSource.password'], p.dataSourceClassName)

try{
//	db.execute('''
//		update t_shop_item set pic_detail1 = '/wx/ind/shop/img/dt-pic1.jpg', pic_detail2 = '/wx/ind/shop/img/dt-pic2.jpg'
//	'''
//	)
	def rows = db.rows('select * from t_shop_item')
	rows.each{
		String a = it.collect{it.key}.join(',')
		String b = it.collect{"'" + it.value + "'"}.join(',')
		println "insert into t_shop_item (${a}) values (${b})"
	}
}catch(e){
	e.printStackTrace()
}finally{
	db.close()
}